cleaned up a little code. distance bug still around