added login/logout logic