major refactoring part II