fixed broken login logic