fixed bug where onIOError was not getting called at the right place