Added distance check, moved location stuff to location.js