checking for nil along with emptiness

related to issue #5