Merged the three functions which queried the row count of tables into one function (countRows)