Corrected undef var issue