Move code from dispatcher to filter