Implemented the the app logic