Fix bug where comparing to undefined variable