added lots of js, but stuck on a bug