wrote menu state code