Refactor navbar JS