moved Haversine distance function from view to controller