fixed the TDM error as well as the weird output