Fixing login control flow