Added error handling for failed subprocess call