refactoring to OO design, lots of comments