I’ll add another piece that may be helpful as well (if this is redundant, I apologize, as I didn’t have a chance to look at Darren’s sample).
With the setup that you’re using, if the learner revists the page, they may have to click the buttons again in order to get the next button to appear depending on how you configured the page to hide the next button. I’ve used a similar approach to control the next button, text on a page or even which image appears based on variables.
For the next button, what I have typically done is add this action at the top of the page:
OnShow: Show Next IF variable1 = true, variable2 = true, etc.
Else: Hide next.
This will determine whether to show or hide the next button when the page loads. I use this method rather than the visited state of the page, as it seems to be less quirky.