This complete block should be fixed with proper variable names, parentheses on new lines, using `&&` instead of `AND` etc.