refactoring main_arr and main_pair