Adapt the code for use in TDDD39