improving error handling in init