login refactor phase 2, still more to do