nav js totally refactored and improved