Mpved some logic to PageController