Split up code
Check in a working client authentication loop.