change API of restrictPage to make it easier to use