add argument for output directory and test for its existence