Moved code to js file.