Find nearest available dock, refactors code