add getindex and addindex function