restructured login behavior