I implemented a machine base class and 4 derived class to keep track of the states more easily