Formalize mainSelected check.

This change helps to make the code more literate.