SLSTR image to fix them

Good afternoon, I am dealing with SLSTR images, and I notice that often when images are particularly bright many artifacts come out, especially because of saturation or non valid pixels, and it is quite clear by looking at the related masks. I would like to fix those artifacts with some band maths operation, for example creating a new band and replacing the saturated pixels with a specific pixel value, but it seems it does not work.

for example if I use the band math operator, setting this expression :

if S2_exception_an_invalid_radiance == 255 then <pixel value> else S2_radiance_an

the new band I obtain is exactly s2_radiance_an has still the artifacts corresponding deriving from the mask I used

Which is my error? or should I directly move for example to python and create my own bands playing there with math and masks?


Here an example of image with artefacts