Refactoring AppDelegate