reg and login refactor