Used property of Math.sqrt(x) to increase efficiency