How to Use the Changes Function for State Transitions