wrap index calculate