Fix: undefined unvariable 'type'