Cornice by Ceiling - So Close!

Hope you are all well.

My script will select the face of the ceiling and place a cornice. However, it works in some parts but not all. Am I missing something?

Node error: “Curve Join produced more than one wire in PolyCurve” - what does that mean?

Thanks in advance.

Figured it out for anyone who might need it later:

Changed my lists to @L1. (this removed error to PolyCurve.ByJoinedCurves)

and Removed Surface.Bypatch (I did not need it to be a surface again, just required the perimeter)
Removed second Surface.PerimeterCurves accordingly.

Works great.