adapt to Safari (thanks Mr.chitoku)