updated distance functionality