Refactor find directions and distances behaviour.