Login checking code is much easier to read and now works