add main menu and code tidy up