basic restructuring and refactoring