moved script to a javascript file