code for controlling IO devices (in prog)