fixed index offset bug