updated menu handling snippet