fix corner case: out of bound exception in filter