How to detect when all of the matrix cells have been filled out?