adjust build_index method