Worked on issue #33: Added automatic page selection. To be tested.