BUGFIX: WHERE clause grouping