Error in trim() call

Hi Charlie,
While copying my changes over last night I made an error closing some brackets which has shown up for me this morning. I've resolved this issue and tested this out.

Apologies for the bug.