added filtering code