refactoring half way through