FINAL CODE FOR THE ASSIGNMENT