fixed missing variable in index function