fix error handling bugs