add ternary search