fixed table naming bug in where clauses