the result variable captures state so you need to change the state when ...

...you guess