refactoring done, all test passed.
//TODO .. more test, new functionality.