fixed bug in trim()
modified to remove compiller warning