Remove repetition from haversine formula