Consider pulling this out into a `trim` function.