Added dynamic menu creation and fixed handler design