small refactor in Entity factory