LPS-36491 Refactor to reuse logic