Moved script from layout file to js file