Make findCodes function work with multiple elements