added distance functionality