refactored the navbar login code