replacing newString with StringBuffer