reformatting and refactoring to pass jshint
updated minified version
updated demo.html