Added output argument to specify output directory