changed idx counting