refactored menu into subobjects and changed serve() and serveObject to use function(menu)