Fix issue with shared state loop