Optimized calculation of position