clean up code by testing for directory before create attempt