map isn't supported in IE8, so just use JavaScript loop