change js script print from statement to function