extracted creaion and freeing of line data structure (ldats) to two separate functions