fixed error handling in the hzero function