+ fixed some index bugs in the weights calculation