partbaked refactor to support flatten filter