fix error handling and docs