most logic works except pushing pages into array