added some filtering code