Bug: Fixed undefined unvariable 'type'