refactor to repository