Changed the structure to work with repository version 2 and be more generic