fixed login logic