changed code to delete temp files after use