use a function instead of a closure to trim word