better strategy for constructing where clause