LPS-48582 SF - reuse logic when possible

Hi @uka-support 

can you verify these changes still fix the issue? I think the root issue was duplicated logic not being consistent and now it should be more robust. 

Can you please test and let me know?

thank you!