A condition of "if [ $TYPE -eq 2 ]" will only work if $TYPE is an integer and if it is not empty. This is not guaranteed (depending on the code path traversed before. If $TYPE is empty, the previous statement will trigger an error or warning message saying
"bash: [: : integer expression expected"
or
"bash: [: -eq: unary operator expected"
Hence it is more robust to change it into a string comparison, "if [ x$TYPE == x2 ]", where both sides are guaranteed to be treated as a string as well as have a non-empty value.
While I was at it, for consistency in coding style I bulk-converted other (pre-existing) string comparisons along similar lines, even if it didn't seem as critical.