Changed js code to address issue #1