Save previous lines data by data id
Fix bug due to break not respecting foreach