optimizing table updates, js