This method might be easier if you use SliceOutput.