added some more error handling to the fillCells function