def find_closest(pts, time)
      return pts.first if pts.size == 1
      midpoint = pts.size / 2
      if pts.size == 2
        diff_1 = pts[0].time - time
        diff_2 = pts[1].time - time
        return (diff_1 < diff_2 ? pts[0] : pts[1])
      end
      if (time >= pts[midpoint].time) && (time <= pts[midpoint + 1].time)
        return pts[midpoint]
      elsif time <= pts[midpoint].time
        return find_closest(pts[0..midpoint], time)
      else
        return find_closest(pts[(midpoint + 1)..-1], time)
      end
    end
def find_closest(pts, time)
      return pts.first if pts.size == 1
      midpoint = pts.size / 2
      if pts.size == 2
        diff_1 = pts[0].time - time
        diff_2 = pts[1].time - time
        return (diff_1 < diff_2 ? pts[0] : pts[1])
      end
      if (time >= pts[midpoint].time) && (time <= pts[midpoint + 1].time)
        return pts[midpoint]
      elsif time <= pts[midpoint].time
        return find_closest(pts[0..midpoint], time)
      else
        return find_closest(pts[(midpoint + 1)..-1], time)
      end
    end
rubocop:disable Style/GuardClause