refactor menu transition handling