split handler in menu into its own function