Optimize calculations