updated to check "if nil"