fix a bug in linearrangement