Refactor out the mkdir to the main function