implement menu switching function.