got rid of unnecessary square roots - performance improvement