enhanced login logic