check for result size of 0
check for nil
Merge pull request #3 from paulmars/master

Thanks @paulmars!