I receive an error when running my script with the CreateAdGroup.udf.

ERROR : unknown command [Then]!
Script: CreateAdGroup.udf
Line : 74