fixing broken replace sequence