clean up by using popen instead of handrolled pipe