Modified the setLayerUIVIsibility function