Refactor the code to use the policy pattern
(cherry picked from commit 2686bef45d420913e80e34b5aecb152b5eb86ebd)