Updated pages loading code