fix nil variable reference.

PR for #362 

- [ ] xxxxxx