clean up conditionals
catch io errors, such as a file being open