moved JS to external where necessary