created the distance formula