separate reduce repository to function