fix duplicate indexes bug