Moved login code into new LoginBox class