refactored the repositories to prevent code duplication