added better sentence position handling and line clearing