refactor main page-turner for less memory usage