start refactoring to better support testing