move filter into plot return function