fix js bug in safari and firefox