Maybe throw in another (if ... ) around the (cdr ...) at the end, such that if it *is* nil it will get the layer of that object and extract the ACI value.
I wonder if we can still assign acBylayer/"BYLAYER" as a color of a layer... I know it can be done with line types.