better way to remove non-matches