Javascript modifications. Tables kept away from duplicates