clean_temporary_directory method improved