a lot of refactoring....