database logic fully moved out of entities.