Sentence: Tom gave Ralph a lift to school so he wouldn't have to walk.
 Reason: The 'he' refers to ralph because walking is referring to ralph which is the he in the sentence. 
 Question: Is the above reasoning correct or wrong? 