refactor to use []Repository instead of map