this needs to be scoped outside of the lock