refactored version of the app