Fix wrong number of affected elements when index > 0