solve index upper&lower problem.