fix bug in knapsack