serious refactoring