Uncertainty and the optimal level of specialization