fixed exception handling and attribute errors.