Adding filter logic