code reorganization
huge refactoring