I changed math.pow to d*d for efficiency

math.pow is a little slow for my liking, especially when you're only doing a square. This is very slightly more efficient.