Changed Object.keys(obj) to a normal for (var k in obj) loop for ie8 support