Fixing bug in knapsack