slightly modified js