wrote new code for hw3