refactored nav logic