Properly build CSS class names when filtering