refactored, fixed bug in T(x) code
refactored, fixed bug in T(x) code