Revert "simplify makedir"

This reverts commit f1645c4026c16220d8dd801cf26b22a5e5e986bb.
Will be reimplemented when the code don't crash