Move JS code to its own file