debugged dft function