separate function from getTable.php