Fix script

Change from PHP to Javascript