working simulated annealing