refactor login js