Refactoring of getAllPins