refactoring. first draft