add $index, fixes #277

Review URL: https://chromiumcodereview.appspot.com//13915003