Adds logic to build where clause string, also cleans up search partial