code snip for DB iteration