added distance formula but please check my math