Added option to specify output directory