final version for assignment8