code implementing the completed assignment;