Modified to output the array after count