WL-3158 Move logic to helper function