refactor into loadApp method