implementing sumTD method