save pattern and a popstate flag in the stateEvent