better checking for undefined value