Added additional statement to test for nil before comparison.