fix bugs that create duplicated index