Beginnings of working state machine