calculate index