Maybe would be better to change the map that keeps the weights. This parseInt is a rather costly function and will be called for every input row.