Added check for undefined variable
Added check for undefined variable