reorganized source code into a class.