Fix buildWhere for count