Refactoring (half done)