polyfil this function for JS SDK