check for null as well to avoid errors

fixes gkz/grasp#8