fixed bug in collapsing