update topk with the optimized version