Collin Ernst HW6

Need to check if r == NULL before doing this, or else you can get a crash when trying to de-reference r.