calculating index from first/last options