use StringIO properly