Ex3

Add a better algorithm