collapse pages and save their state