Use ensure to close internal table cursor