updated TODO's flattening and comparison functions