edits to element_order function