fix major bug in filter code