added error handle for pre-existing directory