fixing the isEmpty check