Cleaned code to Problem #8