re-login handling refactoring