Refactor EntityService