restucture group filter with ternary operator