cleaned mkdir function to have a better exception