added insatnce replace_all and fixed instance replace