Expanded ToDictionary method to include elementSelector