Move js code into separate file