refactoring of class Line and _insertLineAfter and _insertLineBefore