Initial working version for knapsack