Added smart redirect after login