move ternary_helper to evaluation_tools.h