fix for possible undefined values of 'res'