implemented StateMachine
used switch-case in state machine
implemented repeating syntax
implemented repeat function
implemented repeat function
implemented repeat function