add try catch for dir exists func