making some progress on refactoring