removing reliance on global state