update the combination function with dynamic programming approach, now it is fast