Refactoring. Not done yet