Fixed "next" page logic and button detection