On your original question, where are you implementing Distance? I don’t see it. In the changed code you just provided the same default it already uses, but it looks like the real difference is you are providing a layerMask.
Since you think the issue is distance, but the only thing different is the layerMask, I’d suggest removing the layerMask and just testing with changes to distance to verify that is or is not the problem. When troubleshooting problems it is important to first isolate the issue, and part of that is staying away from changing multiple things at once, or you can end up not knowing which thing you changed is the source or solution to a problem, and make incorrect assumptions.