refactoring to app delegate made