Reverted elem.clear() as it broke everything