use pipe instead of tempfile