Pull request for Issue665

@dretrex 
@davidChevrier 
If possible, implement for loop optimization here.  I can imagine large databases having large lists.