Which sentence best corrects the clause fragment?

When Thomas got a new bike for his birthday. He gave his old bike to his little brother.


Thomas gave his old bike to his little brother. When he got a new bike for his birthday.

He gave his old bike to his little brother. When Thomas got a new bike for his birthday.

When Thomas got a new bike for his birthday, he gave his old bike to his little brother.

He gave his old bike to his little brother, when Thomas got a new bike for his birthday.