refactoring $em