fixed bug in basicCollapse function