add code for index_optimize (aka flatten)