changes to I/O code part 1