Partial fix for where clause, still issues