Optimization. Added global mean