cast __toString to string and remove trailing whitespace