Reimplemented simulated annealing