second attempt at problem 2