Updated login logic