fix cast for the case when 'type' is an array

fix cast for the case when 'type' is an array
change string comparison to indexOf search that works both for strings and arrays