refactor filter and generator, move filter into generator