Added smart redirection on login