Moved stuff out of the IO do block