Optimizing argmax search