fix error handling in tasks