modifying state_machine to save position