working on distance formula, making it a loop