To have all that happened only in Bethlehem, then one would have to explain getting in the magi during this time beLow the purification.
for the magi after they left the house an angel came and told Joseph to take Mary and the child to Egypt and they left for Egypt.
After they finish what was required of them in the temple you will read below the last verse they went back home to Nazareth. Luke 2:39
Lk2:21 On the eighth day, when it was time to circumcise him, he was named Jesus, the name the angel had given him before he had been conceived.
Lk2:22 When the time of their purification according to the Law of Moses had been completed, Joseph and Mary took him to Jerusalem to present him to the Lord
Lk2:23 (as it is written in the Law of the Lord, "Every firstborn male is to be consecrated to the Lord"
Lk2:24 and to offer a sacrifice in keeping with what is said in the Law of the Lord: "a pair of doves or two young pigeons."
Lk2:25 Now there was a man in Jerusalem called Simeon, who was righteous and devout. He was waiting for the consolation of Israel, and the Holy Spirit was upon him.
Lk2:26 It had been revealed to him by the Holy Spirit that he would not die before he had seen the Lord's Christ.
Lk2:27 Moved by the Spirit, he went into the temple courts. When the parents brought in the child Jesus to do for him what the custom of the Law required,
Lk2:28 Simeon took him in his arms and praised God, saying:
Lk2:29 "Sovereign Lord, as you have promised, you now dismiss your servant in peace.
Lk2:30 For my eyes have seen your salvation,
Lk2:31 which you have prepared in the sight of all people,
Lk2:32 a light for revelation to the Gentiles and for glory to your people Israel."
Lk2:33 The child's father and mother marveled at what was said about him.
Lk2:34 Then Simeon blessed them and said to Mary, his mother: "This child is destined to cause the falling and rising of many in Israel, and to be a sign that will be spoken against,
Lk2:35 so that the thoughts of many hearts will be revealed. And a sword will pierce your own soul too."
Lk2:36 There was also a prophetess, Anna, the daughter of Phanuel, of the tribe of Asher. She was very old; she had lived with her husband seven years after her marriage,
Lk2:37 and then was a widow until she was eighty-four. She never left the temple but worshiped night and day, fasting and praying.
Lk2:38 Coming up to them at that very moment, she gave thanks to God and spoke about the child to all who were looking forward to the redemption of Jerusalem.
Lk2:39 When Joseph and Mary had done everything required by the Law of the Lord, they returned to Galilee to their own town of Nazareth.