extracted base logic for repository