fix a bug which will result in infinte loop
merge