tighten logic, create directories on the fly