Problem #3 solved in a better way.