bug fix applyWhere