fix safari typeError undefined is not a function