completed refactoring of app delegate