successful solution for hw2.3