fixed code assigning method - it assigned to a bucket that did not have enough capacity. Now we will check the require capacity before assigning the code.