Check nil to fix issue #25