improved clarity of menuitem click function