refactoring to mutualize code between the two implementations