Changing conditional statements used to determine if `res` has been terminated