hw10 fixed javascript function wrapper