replaced some popen calls with native alternatives