Directory creation logic