reorganize and direct optimization