finished. code as submitted for hw1