partition before filtering