Bug fix in WHERE clause