Added more login logic