Extracted a method to get the logon query

It's not perfect, but I'm willing to Close #21