issue #59: verify result is valid before trying to use it.

fixes issue #59