moved the javascript into a class