fixes to page tree function