fix error handling style & remove fprints