functional version of io_func