fix nil variable reference.

PR for #362