Set 1 : Challenge 4
Also some refactoring