added some err checking to ed