implemented first part of homework #8