more tedious I/O code