Fixed some conditions when  errors as undefined.