implement IO primitives