Split login function

I've added a new function, pswCheck() via splitting the login function and reusing the code.