started commenting code, added demo, improved javascript