my solution to 6