fix switch variable out of range