changing code to return javascript instead of html