added line replacement function that replaces existing lines instead of just re-adding them and causing the QS to freeze on a second run