reset temporary array at each iteration