added undefine check