Changed to jquery string trim function where needed