working, though output files seems to be overwritten