Refactor DBEntsafter