fix some I/O bug