Added page change state logic