Fixed incorrect javascript update logic