added error check on connecting nodes