modified "toLine" method