update stack[i]