Fixed mistake in merging states