[issue #1086] grab the correct dataset information

This fixes the issue of values being overwritten by the last value of the loop as reported in #1086