Finding closest beacon

It seemed like it was finding the farthest beacon instead of the
closest. Needs more testing.