Fix collapse functionality