Fix index bug (issue #1896)