Fixed the distance finding algorithm to do pow(delta,2) instead of pow(delta, dimensions)