debug distance loop, make other logic edits