first draft of the corrected SFTD algorithm