refactor login and helpers