Final version of exercise1