works, but have trouble writing results to disk