refactor data transformation