Removed unnecessary duplication, added mkdir return value validation