some serious refactoring