refactored navbar code