added distance var and comment