Moved the app code into a class so it will be easier to test