better way to use with undefined var