changed Ni to set in traverse_history