fixed bug with calculation of tf weights