change minimize algorithm