fixing replace errors