Do not use replaceInArray since the array may may have changed
Remove unused function