minor bug with undefined checking fixed