factored out distance function from map drawing so it can be swapped out easily later