Used the IO monad instead of direct IO