corrected bug in tf calculation