Did not know this, I assumed that the local variable `err` would've been in the scope of the deferred function. Will update accordingly