code updated for hw7