added -p flag to mkdir in the `mcdir()` function in order to create intermediate directories if required