refactoring part3 (nearly finish 'framework')