Refactor the app file