countTable and countRow functions