While he was trying to figure a way out, he had a dream. God's angel spoke in the dream: "Joseph, son of David, don't hesitate to get married. Mary's pregnancy is Spirit-conceived. God's Holy Spirit has made her pregnant. She will bring a son to birth, and when she does, you, Joseph, will name him Jesus—'God saves'—because he will save his people from their sins." This would bring the prophet's embryonic sermon to full term:
Watch for this—a virgin will get pregnant and bear a son;
They will name him Immanuel (Hebrew for "God is with us").
Then Joseph woke up. He did exactly what God's angel commanded in the dream: He married Mary. But he did not consummate the marriage until she had the baby. He named the baby Jesus." Matt 1:18-25 ...Just a thought.