fixed javascript functionality