Successful solution for Problem 5