Attempt at problem six