added code to create dirs as needed