Error handling is good, moved the client stuff into the loop.