improved bugs for closing EntityManager after method ends