Fixed calculation of pages when chaning permissions
checking for sideeffects when page was changed