Fixed wrong variable ref in filtering code