refactor to handle any order of chains in ti
#28
+1,018
−5
Merged
ti
#28