whoops introduced new issue because of global state.. going to need to refactor later to get rid of that..