new filtering code but still not stable...