moving all that nasty js to an external file