functionized the save array in main