updated code for index