Only reset the array when needed