refactored generateMenu() to return instead of echo