Refactored out duplicated code from get_distance_to_exit_point and get_distance_to_entry_point methods. Using lambda expressions for different distance calculation algorithms.