Added null check to undef function.