LPS-44098 Make logic easier to understand and reduce the probability of making errors