smarter login redirection