Correct If and EndIf and add LOGICAL_NOT