optimized coords calculation