separate the menu part and fix a bug