reorders the phases