Replaced trim with something that works with IE8
added the test hasOwnProperty for each : for in