fixed code to insert a formula element when the same priority element is added.