refactoring app startup algorithms