Since pieces is always an array, use proper .length looping