optimized calculation