my own modified version for extract table names from sql