switch from tempfile to io