You can add an extra argument `done` to this function and call that with the result `get_next_state()` once the answer has been stored.