fixing a bug with "sim" variable in "execute" functions.