Change order in algorithm