refactoring login js