Update trim method

Change a chain of `replace` with one `replace`. This should work faster.