Fix error in stateful code!
Refactor for exception.