Extracted addPrefixes method