Added checks when making directories