math.sqrt is significantly faster than ** .5, so I replaced the function