create an array 2 rows and cols larger then necessary (row 0 -row before the actual array and row 7 - row after, same with cols) and initialize them with values different from the possible array values. Check them later when iterating through cells (sorry, won't help with that)

Good luck

Andrei