refactored entity transformation