make this js function not error out when run on the wrong page