login method + refactor