changed distance calculation