replace this line in the update
var %Mode = $mid(%mode,1,1) $+ $Mid(%mode,%a,1)
with this
var %Mode = $mid($1,1,1) $+ $Mid($1,%a,1)