Moved undefined checking