Finalising filtering code