correctly handling the output directory path