fixing indices problem