def closer_to_target(prev_option, route, original_run):
    """
    Parameters
    ----------
    prev_option : tuple (routes json, distance float)
        previous distance.
    routes : json object
        routes json related to the current closest option.
    distance : float
        current calculated distance.
    original_run : float
        current target distance for the run.

    Returns
    -------
    (routes, distance) : tuple (routes json, distance float)
        closest tuple to the distance run

    """
    prev_distance = prev_option.distance
    prev_distance_error = abs(original_run - prev_distance)
    distance_error = abs(original_run - route.distance)
    
    #check the lowest error to the target
    if prev_distance_error < distance_error:
        return prev_option
    
    return route