Completed version of exercise five