Optimizations made

Changed Euclidean distance to hypot function to avoid overflow.