final version for class assignment