Refactored code in respect to the entity system framework