fixed error handling in init method