Fix bug with indices