avoid generating nested function