Added a bit more login logic