solve problem #6