refactor interrupt and restart function
rename file only after filename has been set