added extending lines to work correctly

Fixed bug undo did not work properly after checking soln due to sorting