Implemented the first phase of exercise 3