moved TernaryFunction to separate file