refactoring. main must be small