Do this validity check before doing any of the other work.

Also, use dot notation to access properties.