function countElements added to get total number of rows to each table