added ability to specify output directory