Removing illogical lines