added rescue for nilclass