"tablescan" should be its own special case, handled by a short parseTable function. Also call parseTable (and do the other stuff) from inside the loop in parseTables.