update page break: add and remove page as required. tidy up code