$opt_type is not always defined, solving 'undefined value' message