condition fixed for logging error message