improve IO exception handling