re-factored code for menu, active menu and routes.