making stateful APIs pure chapter