Move script to javascript file