Refactoring data handling