now with login/logout.
refactoring