added support for outputing several samples