tweak code to handle multiple lines in one set of data