added random number to temporary files to avoid clashing