refactor io/out
Now we use QueryExecutionFactory to make it more general