Moved JavaScript into separate files