made temp file an optional argument