refactoring and fixing some behaviors of the nav module