Calculate index