change 'undef' return value to NULL