Added a simple state machine

Will certainly be modified in the future but for now it's ok