fix collapse code