fix bug: when a paramter called times is used. using nested function