Cleaned up createDir function