optimize lua function call