Help with navigation logic

Hi,

I am trying to dynamically assign “next” and “back” values to my buttons. I have 2 arrays; Next is empty, Back has “step1” in it.

When a user makes their selection, say a,b,c or d from step1. That value is pushed into the Next array.

next.push(value);

They then make a selection from this page, say, e,f,g or h. Now, the new value is pushed into next and the old value is pushed into back. eg

back.push(next.pop());
next.push(newValue);

if a user clicks on Back, the value is retrieved from the array, then popped.

gotoAndStop(back.pop());

This goes on for 3 more steps (pending on their selections).

The problem is, if they select say a on step 1 but change their mind and select b before hitting Next, both values are pushed into the next array.

Just from writing this I see I should move the array.push to the next function but I am wondering if anyone has any better suggestions.

Help or suggestions are appreciated.

Deborah