I would change this to `if (type) {`.