How to switch AppStates in a correct way

Hey guys.

i have a question and neither the tutorial nor the book could help me.
What is the correct way to switch / replace AppStates?

Here a little pseudocode:

SelectGame extends AbstractAppState{
   Level level = null;

 initialize(){
     level = new Level1State();
     stateManager.attach(level);


  }

 void switchState(){
    stateManager.detach(level);
    level = new Level2();
    stateManager.attach(level);

 }

}

Level1State extends AbstractAppState{

initialize(){
//do awesome stuff here
}

void finish(){
stateManager.detachState(this); //detach here?
//or
stateManager.getState(SelectGame.class).switchState();
}

}

Hope, this code helps to understand what i mean. I can not start level2 directly from the level1 because there a lot things todo for example (show highscore, or load some stuff)

Cheers,

Dominique

Is the way you have it causing problems?