Fix a bug where state was maintained over multiple calls