Added extra code to support Chrome and Safari