add logic for invalid/truncated lines