use subprocess and fix and logging