Added missing 'if (!err) {' line