Fixed a bug that broke the code when the type directory was not already created