Fix the bugs for filter data function