bugfixing for replace index