Refactored the sample app a little bit