finished first part of homework 3, verified solution