Patching up javascript logic.............