Understanding the concepts of a State Machine