add error checking to subprocess