Replaced query in tableExists() with cleaner solution.