adds distance formula