add IO exception handling