Refactored and introduced a state machine to print different kind of menus.