proj1: finished code for subassignment 2