Creating endpoint and fixing the JS Script