refactoring app loader