added completed code for homework 2.2 assignment