seperate compute_topk function