Refactoring main app