start refactor the main() for single array and pair