copied over code from last lab which we reuse this time