fix bug when removing pages