this runs well but there are some infinite loops because some pointers point back to themselves.