add defined check before using variable