fix error message log, variable res not defined