Fix access to undefined variable
Reformat conditional