Functions are used for repetitive code. You've got three sets of events doing exactly the same thing except the name of the layer being checked. Convert one of those blocks to be inside a function, using Function.Param(0) as the name to be checked, and replace the current blocks with a function call.
(You can't use Trigger once in this case, but that's a small loss, and not critical in this case.)