Fix messed up where clause