modified js to fit with other browsers