refactor
detect successful login