Move filter code to header