Modified the directory creation logic.