optimized sqrt usage