porting dynamic_index