refactor BuildWhere