Improve code structure of dailyprogrammer exercise 183.