bug fix in collapsing