Refactor evaluation logic to be reusable.