Replaced `trim` with `rtrim`