refactoring main_action