Solution for prob8