Updated Login logic

While loop would exit prematurely when searching database