Change Algorithm

This is more clear