Fix a bug in filtering