finalized function for checking and (re-)creating directories.