Refactor PageTools.php

Change-Id: I874d3a25b900c876b8219582570c5f00765e3e4d