Changed JS code from inline to external file