replace and getidx added