Bug fix in handling ValueError.