Remove duplicate code on adding repository