<hr> a much better option here.
Adding comments.
Making logic more clear re: the big IF statement.
Adding comment.
Better variable name.
Better spacing.
(Slightly) better variable names.
Argh! Equivalence, not assignment.