refactored to use some iterator in list match