Fix bug in index creation