unset doesn't like @ to silent it, just check if it's set  before unset
Add curly brackets here to improve readability