LPS-42822 encapsulate duplicated logic