magic index problem