Refactored app logic into its own class