Check that both key and value exist

If either the key or the value don't exist then move on. The previous behavior resulted in segmentation faults.