fixed issue with distance (still need to fix more)