Added checkTables function