unset variables in the correct order