Refactor the CNAME lookup into its own function.