JS in separate file, tidy up a bit