some code refactoring for doctrine methods