started implementing ternary search