added subprocess error checking