final version including TTC algorithm