This algorithm looks much better, thank you!